package logic

import (
	"context"
	"rpc/model/redis"

	"rpc/internal/svc"
	"rpc/pb/cart"

	"github.com/zeromicro/go-zero/core/logx"
)

type CartCountLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCartCountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CartCountLogic {
	return &CartCountLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *CartCountLogic) CartCount(in *cart.CartCountRequest) (*cart.CartCountResponse, error) {
	// todo: add your logic here and delete this line
	count := redis.CartCount(in.UserId)

	return &cart.CartCountResponse{Count: count}, nil
}
